package com.zwk.sta.controller;


import com.zwk.base.entity.CommonResult;
import com.zwk.sta.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author zwk
 * @since 2022-09-02
 */
@RestController
@CrossOrigin
@RequestMapping("/sta/daily")
public class DailyController {

    @Autowired
    private DailyService dailyService;

    // 查询某天的注册人数, 加进数据库
    @PostMapping("/registerCount/{day}")
    public CommonResult registerCount(@PathVariable("day") String day){
        dailyService.registerCount(day);
        return CommonResult.ok();
    }

    // 图表显示, 返回需要查询的数据
    @GetMapping("/showData/{type}/{begin}/{end}")
    public CommonResult showData(@PathVariable("type") String type,
                                 @PathVariable("begin") String begin,
                                 @PathVariable("end") String end){
        Map<String, Object> map = dailyService.showData(type, begin, end);
        return CommonResult.ok().data(map);
    }


}

